package com.rskj.cashbook.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rskj.cashbook.response.ResponseEntity;
import com.rskj.cashbook.service.ICashBookService;
import com.rskj.cashbook.vo.Query.QueryBase;
import com.rskj.cashbook.vo.Query.StatementsQueryVo;
import com.rskj.cashbook.vo.ReportDetailVo;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("report")
@AllArgsConstructor
public class ReportController {

    private final ICashBookService cashBookService;

    @PostMapping("/v1")
    public ResponseEntity<PageInfo<ReportDetailVo>> report(@RequestBody QueryBase<StatementsQueryVo> queryBase) {
        PageHelper.startPage(queryBase.getPageNumber(), queryBase.getPageSize());
        return ResponseEntity.ok(new PageInfo<>(cashBookService.cashBookReport(queryBase.getObject())));
    }
}
